package com.sonicboom.nurun.client;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;

public class WeChatClient {
    private final String wechatServerUrl;

    public WeChatClient(String wechatServerUrl) {
        this.wechatServerUrl = wechatServerUrl;
    }

    public String getShareConfig(String url) {
        String targetUrl = String.format(wechatServerUrl+"?url=%s", url);
        ClientResponse response = Client.create().resource(targetUrl).get(ClientResponse.class);
        return response.getEntity(String.class);
    }

    public String getJSShareConfig(String content) {
        ClientResponse response = Client.create().resource(wechatServerUrl).post(ClientResponse.class, content);
        return response.getEntity(String.class);
    }
}
